<template>
	<view class="team clearfix">
		<cu-custom bgColor="bg-white" isBack>
			<block slot="content">{{walletname[type]}}</block>
		</cu-custom>
		<view class="wallet-box discenter flex-direction text-white">
			<image src="/static/wallet/xqbg.png" class="wallet-pic" mode=""></image>
			<text class="por f26">{{balance}}</text>
			<text class="por mt10">{{wallettitle[type]}}</text>
		</view>
		<scroll-view class="scroll-view history px15"  scroll-y @scrolltolower="OnReachBottom">
			<view class="f16 pt15 pb5 fwb">财务明细</view>
			<view class="flex flex-direction wp100" :class="{mb40:type!=2&&type!=6}">
				<view v-for="(item,index) in List" class="flex px15 flex-direction wp100 bg-white radius-5 mt10 py15" :key="index">
					<view >{{item.name}}</view>
					<view class="flex align-center mt20 justify-between">
						<text>数量</text>
						<text>时间</text>
					</view>
					<view class="flex align-center mt10 justify-between">
						<text v-if="item.status==1">-{{item.num}}</text>
						<text v-else class="text-red">+{{item.num}}</text>
						<text class="text-info">{{item.addTime}}</text>
					</view>
				</view>
			</view>
		</scroll-view>
		<view class="wallet-end text-white px15" v-if="type!=2&&type!=6">
			<!-- 余额 -->
			<view class="wp100 flex align-center justify-between hp100" v-if="type==0">
				<view class="wallet-button discenter" @click="pushPage('/pages/wallet/recharge?type='+type)">充值</view>
				<view class="wallet-button discenter" @click="pushPage('/pages/wallet/licai')">理财</view>
				<view class="wallet-button discenter" @click="pushPage('/pages/wallet/tixian')">提现</view>
			</view>
			<!-- 益豆 -->
			<view class="wp100 flex align-center justify-between hp100" v-if="type==1">
				<view class="wallet-button discenter" @click="pushPage('/pages/wallet/recharge?type='+type)">充值</view>
				<view class="wallet-button discenter" @click="pushPage('/pages/wallet/zqq?type='+type)">转换期权</view>
				<view class="wallet-button discenter" @click="pushPage('/pages/wallet/zgp')">转换股票</view>
			</view>
			<!-- 分红 -->
			<view class="wp100 flex align-center justify-between hp100" v-if="type==3">
				<view class="wallet-buttons discenter" @click="pushPage('/pages/wallet/zye?type='+type)">转换余额</view>
				<view class="wallet-buttons discenter" @click="pushPage('/pages/wallet/zqq?type='+type)">转换期权</view>
			</view>
			<!-- 余利宝 -->
			<view class="wp100 flex align-center justify-between hp100" v-if="type==4">
				<view class="wallet-buttons discenter" @click="pushPage('/pages/wallet/zye?type='+type)">转换余额</view>
				<view class="wallet-buttons discenter" @click="pushPage('/pages/wallet/zqq?type='+type)">转换期权</view>
			</view>
			<!-- 拼团余额 -->
			<view class="wp100 flex align-center justify-between hp100" v-if="type==5">
				<view class="wallet-buttons discenter" @click="pushPage('/pages/wallet/zye?type='+type)">转换余额</view>
				<view class="wallet-buttons discenter" @click="pushPage('/pages/wallet/zqq?type='+type)">转换期权</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
	data() {
		return {
			type:'',
			id:'',
			balance:'0.00',
			walletname:['余 额','邦 豆','期 权','分 红','种 子','拼团余额','股 票'],
			wallettitle:['余 额','邦 豆','期 权','总分红','余 额','余 额','股 票'],
			historyUrl:['wallet.yue','wallet.yidou','wallet.qiquan','wallet.fenhong','wallet.yulibao','','wallet.gupiao']
		}
	},
	onLoad(e) {
		this.type=e.type
		
	},
	onShow() {
		this.clearData()
		this.getData()
	},
	methods: {
		OnReachBottom(){
			this.getData()
		},
		clearData(){
			this.List=[]
			this.page=1
			this.finish=false
		},
		async getData() {
			if (this.finish) return
			let {
				data:{logs,yueNum}
			} = await this.$http.post(this.historyUrl[this.type], { page: this.page,limit:20 })
			if(this.page==1){
				this.balance=yueNum
			}
			this.finish = logs.length < 20
			!this.finish && (this.page += 1)
			this.List = [...this.List, ...logs]
		},
	}
}
</script>

<style lang="less">
.wallet-box{
	width: calc(100% - 60rpx);
	margin-left: 30rpx;
	height: 300rpx;
}
.por{
	position: relative;
	z-index: 1;
}
.wallet-pic{
	width: calc(100% - 60rpx);
	height: 300rpx;
	position: absolute;
	top: 52px;
}
.wallet-end{
	position: fixed;
	bottom: 0;
	width: 100%;
	height: 110rpx;
	background-color: #FFFFFF;
}
.wallet-button{
	width: 220rpx;
	height: 80rpx;
	background-color: #D73329;
	border-radius: 10rpx;
}
.wallet-buttons{
	width: 336rpx;
	height: 80rpx;
	background-color: #D73329;
	border-radius: 10rpx;
}
</style>
